package lvcy.message.sender.factory.impl;


import lvcy.message.sender.builder.MessageSenderBuilder;
import lvcy.message.sender.builder.impl.DxtSingleMessageSenderBuilder;
import lvcy.message.sender.builder.impl.HytSingleMessageSenderBuilder;
import lvcy.message.sender.builder.impl.JstSingleMessageSenderBuilder;
import lvcy.message.sender.factory.MessageSenderBuilderFactory;

import java.lang.reflect.Constructor;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;


public class SingleMessageSenderBuilderFactory extends MessageSenderBuilderFactory{

	private Logger log=LogManager.getLogger(this);
	public final static SingleMessageSenderBuilderFactory INSTANCE=new SingleMessageSenderBuilderFactory();
	private SingleMessageSenderBuilderFactory() { }
	@Override
	public MessageSenderBuilder createJstMessageSenderBuilder() {
		try {
			Class<?> clazz=Class.forName(JstSingleMessageSenderBuilder.class.getName());
			Constructor<?> constructor=clazz.getConstructor();
			this.builder=(MessageSenderBuilder) constructor.newInstance();
		} catch (Exception e) {
			log.error(e);
		}
		return builder;
	}

	@Override
	public MessageSenderBuilder createHytMessageSenderBuilder() {
		
		try {
			Class<?> clazz=Class.forName(HytSingleMessageSenderBuilder.class.getName());
			Constructor<?> constructor=clazz.getConstructor();
			this.builder=(MessageSenderBuilder) constructor.newInstance();
		} catch (Exception e) {
			log.error(e);
		}
		return builder;
	}

	@Override
	public MessageSenderBuilder createDxtMessageSenderBuilder() {
		try {
			Class<?> clazz=Class.forName(DxtSingleMessageSenderBuilder.class.getName());
			Constructor<?> constructor=clazz.getConstructor();
			this.builder=(MessageSenderBuilder) constructor.newInstance();
		} catch (Exception e) {
			log.error(e);
		}
		return builder;
	}
	public static SingleMessageSenderBuilderFactory getInstance(){
		return INSTANCE;
	}

}
